{include file='public/head' /}
{include file='public/left' /}
<div class="main" style="padding:10px;">
    <div class="content">
        <span>管理员列表</span>
        <button class="layui-btn  layui-btn-sm" onclick="add()">添加</button>
        <div></div>
    </div>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>账户</th>
            <th>姓名</th>
            <th>状态</th>
            <th>添加时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name='admin' id='admin_v'}
        <tr>
            <td>{$admin_v.uid}</td>
            <td>{$admin_v.account}</td>
            <td>{$admin_v.name}</td>
            <td>{if $admin_v.status==1}开启{else/}关闭{/if}</td>
            <td>{$admin_v.add_time}</td>
            <td><button class="layui-btn layui-btn-xs"
                        onclick="edit({$admin_v.uid})">修改</button>
                <button class="layui-btn layui-btn-xs layui-btn-danger"
                        onclick="del({$admin_v.uid})">删除</button></td>
        </tr>
        {/volist}
        </tbody>
    </table>
</div>
<script type="text/javascript">
    function add(){
        layer.open({
            title: '添加',
            type:2,
            shade:0.3,
            area:['480px','440px'],
            content: '/admin/admin/add'
        });
    }
    function del(uid){
        layer.confirm('确定要删除吗？', {
            icon:3,
            btn: ['确定','取消']
        }, function(){
            $.post('/admin/admin/del',{'uid':uid},function(res){
                if(res.code>0){
                    layer.alert(res.msg,{icon:2});
                }else{
                    layer.msg(res.msg);
                    setTimeout(function(){window.location.reload();},1000);
                }
            },'json');
        });
    }
    function edit(uid){
        layer.open({
            title: '修改',
            type:2,
            shade:0.3,
            area:['480px','440px'],
            content: '/admin/admin/edit?uid='+uid
        });
    }
</script>
{include file='public/bottom' /}